package com.project.lk.nurseapp.home.usermsg.presenter;


import com.project.lk.nurseapp.base.BaseApi;
import com.project.lk.nurseapp.base.BasePresenter;
import com.project.lk.nurseapp.base.ModelPresenterBridge;
import com.project.lk.nurseapp.home.usermsg.model.PostFileHintBean;
import com.project.lk.nurseapp.home.usermsg.model.PostImageModel;
import com.project.lk.nurseapp.home.usermsg.model.PostUserIconModel;
import com.project.lk.nurseapp.home.usermsg.model.UpdateUserModel;

import java.util.List;

/**
 * 功能介绍：
 * 项目名：
 * 模块名称：
 * 作者：LK
 * 日期：2018/1/9
 * 修改日期：
 */
public class UserMsgPresenter extends BasePresenter<IUpdateUserView> implements ModelPresenterBridge {
    PostImageModel postImageModel;
    UpdateUserModel updateUserModel;
    private final PostUserIconModel postUserIconModel;

    public UserMsgPresenter(IUpdateUserView view){
        addView(view);
        postImageModel=new PostImageModel();
        updateUserModel=new UpdateUserModel();
        postUserIconModel = new PostUserIconModel();
        postUserIconModel.setBridge(this);
        postImageModel.setBridge(this);
        updateUserModel.setBridge(this);
    }

    public void postImg(String url,String path){
        postImageModel.postLoadJson(url,path);

    }

    public List<PostFileHintBean> getImgList(){
        return postImageModel.getmList();
    }

    public void updateUser(String url,String nickname,String sex,String birthday,String mobile){
        updateUserModel.postLoadJson(url,nickname,sex,birthday,mobile);
    }

    public void postUserIcon(String url,String headImgUrl){
        postUserIconModel.postLoadJson(url,headImgUrl);
    }

    @Override
    public void bridge(int action, List list) {
        if (view!=null) {
            switch (action){
                case BaseApi.img_success:
                    view.postImgSuccess();
                    break;
                case BaseApi.img_fail:
                    view.postImgFail();
                    break;
                case BaseApi.post_usericon_success:
                    view.updateIconSuccess();
                    break;
                case BaseApi.post_usericon_fail:
                    view.updateIconFail();
                    break;
                case BaseApi.update_success:
                    view.postUserMsgSuccess();
                    break;
                case BaseApi.update_fail:
                    view.postUserMsgFail();
                    break;
            }
        }

    }
}
